package com.molin.DateTest.jdk8DateTest;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

public class Demo5 {
    public static void main(String[] args) {
        //格式化
        LocalDateTime localDateTime=LocalDateTime.now();
        System.out.println(localDateTime);
        DateTimeFormatter dateTimeFormatter=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        String s= localDateTime.format(dateTimeFormatter);
        System.out.println(s);

        //解析
        LocalDateTime ld=LocalDateTime.parse(s,dateTimeFormatter);
        System.out.println(ld);
    }
}
